//
//  CaseDetailViewController.m
//  e律师
//
//  Created by 韦淋 on 2017/5/16.
//  Copyright © 2017年 test. All rights reserved.
//

#import "CaseDetailViewController.h"
#import "CaseDetailCell.h"
#import "CaseIntroduceViewController.h"
#import "CaseInfoViewController.h"
#define SCREEN_SIZE [UIScreen mainScreen].bounds.size
#define LEFTSIDE_WIDTH (SCREEN_SIZE.width * 0.5)

@interface CaseDetailViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, strong) NSMutableArray *caseDataSource;
@property (nonatomic, strong) UITableView *caseTableView;
@end

@implementation CaseDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.caseTableView];
}


#pragma mark - Button Target
- (void)toNext:(UIButton *)sender{
    CaseIntroduceViewController *caseIntroduceVC = [[CaseIntroduceViewController alloc] init];
    [self.navigationController pushViewController:caseIntroduceVC animated:YES];
}


#pragma mark - UITableViewDelegate/UITableViewDataSource
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 6;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 300;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    CaseDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"caseCell" forIndexPath:indexPath];
    cell.titleLable.text = @"hdjksfhjsadhfjksadhf";
//    cell.arrowImageView.image = [uiim]
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.backgroundColor = [UIColor blueColor];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    CaseInfoViewController *caseInfoVC = [[CaseInfoViewController alloc] init];
    caseInfoVC.tag = indexPath.row;
    [self.navigationController pushViewController:caseInfoVC animated:YES];
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIView *space = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 400)];
    
    UILabel *caseTitleLable = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, 365, 50)];
    caseTitleLable.backgroundColor = [UIColor blueColor];
    caseTitleLable.text = @"刘佳文杀人案 ";
    caseTitleLable.textColor = [UIColor whiteColor];
    caseTitleLable.layer.cornerRadius = 5;
    caseTitleLable.layer.masksToBounds = YES;
    
    UIButton *caseButton = [[UIButton alloc] initWithFrame:space.frame];
    [caseButton addTarget:self action:@selector(toNext:) forControlEvents:UIControlEventTouchUpInside];
    
    [space addSubview:caseButton];
    [space addSubview:caseTitleLable];
    return space;
}
#pragma mark - Getter
- (UITableView *)caseTableView{
    if (!_caseTableView) {
        _caseTableView = [[UITableView alloc] initWithFrame:CGRectMake(5, 0, SCREEN_SIZE.width - 10, SCREEN_SIZE.height ) style:UITableViewStyleGrouped];
        _caseTableView.backgroundColor = [UIColor whiteColor];
        _caseTableView.delegate = self;
        _caseTableView.dataSource = self;
        _caseTableView.estimatedRowHeight = 10;
        _caseTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_caseTableView registerClass:[CaseDetailCell class] forCellReuseIdentifier:@"caseCell"];
    }
    return _caseTableView;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
